package com.naiterui.ehp.bs.patient.controller;

import com.naiterui.common.redis.RedisUtil;
import com.naiterui.common.repository.page.PageParamVO;
import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.constants.SwaggerTags;
import com.naiterui.ehp.bp.support.context.ResourceHolder;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.JsonException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bp.support.security.SettingConfig;
import com.naiterui.ehp.bs.patient.exception.ExceptionCodes;
import com.naiterui.ehp.bs.patient.service.IDrMedicationRecomService;
import com.naiterui.ehp.bs.patient.service.IPatientDoctorService;
import com.naiterui.ehp.bs.patient.utils.CacheUtils;
import com.naiterui.ehp.bs.patient.utils.cache.PatientCacheUtil;
import com.naiterui.ehp.bs.patient.utils.constants.PatientConstant;
import com.naiterui.ehp.bs.patient.utils.exception.PatientBusinessException;
import com.naiterui.ehp.bs.patient.vo.doctor.DoctorCheckVO;
import com.naiterui.ehp.bs.patient.vo.doctor.DoctorVO;
import com.naiterui.ehp.bs.patient.vo.doctor.VideoConsultVO;
import com.naiterui.ehp.bs.patient.vo.patient.PersonalRelation;
import com.naiterui.ehp.bs.patient.vo.requestparam.PatientDoctorVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

/**
 * 患者与医生相关业务接口
 *
 * @version 2015年6月22日 下午12:00:21 by Amber
 * @Description 患者绑定私人医生、关注医生、评价医生、查询医生等相关接口
 */
@Api(tags = {SwaggerTag.PATIENT + SwaggerTag.RELATIONSHIP})
@RequestMapping("ap/patient/doctor")
@RestController
@AllArgsConstructor
public class ApPatientDoctorController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ApPatientDoctorController.class);

    private final IPatientDoctorService patientDoctorService;
    private final IDrMedicationRecomService drMedicationRecomService;


    /**
     * 患者绑定医生
     * 患者扫描医生二维码绑定私人医生关系
     *
     * @param doctorId  医生推荐码
     * @param patientId 患者id
     *
     * @return
     *
     * @History 2015年6月21日 上午11:21:35 by Amber
     */
    @ResponseBody
    @RequestMapping(value = "bind", method = RequestMethod.POST)
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public PersonalRelation addPersonalDoctor(Long doctorId, Long patientId, Integer firstRecom, Integer isOld) throws Exception {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("患者绑定医生 请求参数：doctorId = [{}], patientId = [{}], firstRecom = [{}], isOld = [{}]", doctorId, patientId, firstRecom, isOld);

        String doctor = null;
        try {
            // 参数校验
            if (patientId == null || patientId < 0 || doctorId == null || firstRecom == null || isOld == null) {
                LOGGER.error("patient doctor bind ERROR ; illegal param : doctorId {},patient {},firstRecom {},isOld{}", doctorId,
                        patientId, firstRecom, isOld);
                throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
            }

            // 来自1.0旧二维码的绑定请求，终止绑定，提示用户：医生二维码已过期，如有问题请咨询客服热线020-29198502。
            if (isOld == 1) {
                LOGGER.error("patient doctor bind ERROR ; useless QC code : doctorId {},patient {},firstRecom {},isOld{}", doctorId,
                        patientId, firstRecom, isOld);
                throw new PatientBusinessException(ExceptionCodes.PATIENT_DOCTOR_CODE_EXPIRE);
            }

            doctor = patientDoctorService.getDoctorName(doctorId);
            // TODO:密钥校验x
            PersonalRelation personalRelation = patientDoctorService.addPersonalDoctor(doctorId, patientId, firstRecom,
                    PatientConstant.PERSONAL_SOURCE_WEIXIN);

            if (firstRecom == 1) {// 新患者推送消息关联第一个推荐医生
                // 更新患者缓存(患者注册为完善资料缓存-供三天推送资料使用)
                updatePatientRedis(patientId, doctor);
            }
            return personalRelation;
        } catch (BusinessException e) {
            if (e.getCode() == ExceptionCodes.HAVE_BOUND) {
                // 已绑定提醒信息格式化
                throw new BusinessException(e.getCode(), String.format(PatientConstant.HAVE_BINDED_DOCTOR, doctor), null);
            }
            throw e;
        }
    }

    /**
     * 更新新患者最新绑定医生信息
     * PatientDoctorController.updatePatientRedis()<BR>
     * <P>Author : Amber </P>
     * <P>Date : 2015年9月16日 </P>
     *
     * @param patientId
     * @param doctor
     */
    private void updatePatientRedis(Long patientId, String doctor) {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        try {
            if (patientId == null || StringUtils.isBlank(doctor)) {
                LOGGER.error("updatePatientRedis ERROR ; patientId or doctor is null : patientId {}, doctor {}", patientId, doctor);
                return;
            }
            PatientCacheUtil.updateNewPatientDoctor(patientId, doctor);

        } catch (Exception e) {
            LOGGER.error("updatePatientRedis ERROR ; patientId {}, doctor {}", patientId, doctor, e);
        }
    }

    /**
     * 关注医生
     *
     * @param doctorId  医生id
     * @param patientId 患者id
     *
     * @return
     *
     * @History 2015年6月21日 下午9:15:32 by Amber
     */
    @ResponseBody
    @RequestMapping("attend")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public DoctorVO attendDoctor(Long doctorId, Long patientId) throws Exception {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        // 参数校验
        if (doctorId == null || doctorId < 0 || patientId == null || patientId < 0) {
            LOGGER.error("patient doctor attend ERROR ; illegal param : doctorId {},patientId {}", doctorId, patientId);
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }
        // TODO:密钥校验
        DoctorVO doctorVo = patientDoctorService.addAttendDoctor(patientId, doctorId);
        doctorVo.setFansNum(patientDoctorService.getDoctorFansNum(doctorId));
        // 更新医生新增粉丝数缓存
        String key = CacheUtils.getDoctorNewFansKey(doctorId);
        addDoctorNewNums(key, 1);

        LOGGER.info("patient doctor attend SUCCESS ; doctorId {},patientId {}", doctorId, patientId);
        return doctorVo;
    }

    /**
     * 取消关注
     *
     * @param doctorId  医生id
     * @param patientId 患者id
     *
     * @return
     *
     * @History 2015年6月21日 下午10:12:34 by Amber
     */
    @ResponseBody
    @RequestMapping("cancel")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public DoctorVO cancelAttend(Long doctorId, Long patientId) throws Exception {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        DoctorVO doctorVo = patientDoctorService.deleteAttend(patientId, doctorId);
        doctorVo.setFansNum(patientDoctorService.getDoctorFansNum(doctorId));

        LOGGER.info("patient doctor cancel SUCCESS ; doctorId {},patientId {}", doctorId, patientId);
        return doctorVo;
    }

    /**
     * 查找医生
     *
     * @param keyword      关键字
     * @param departmentId 部门id
     * @param cityId       城市id
     *
     * @return
     *
     * @History 2015年6月23日 上午10:48:11 by Amber
     */
    @ResponseBody
    @RequestMapping("find")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageVO<DoctorVO> findDoctors(String keyword, Integer departmentId, Integer cityId, Long patientId,
        PageParamVO pageParamVO) throws BusinessException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("查找医生(find) 请求参数：keyword = [{}], departmentId = [{}], cityId = [{}], patientId = [{}], pageParamVO = [{}]", keyword, departmentId,
                cityId, patientId, pageParamVO);
        if (keyword == null) {
            keyword = "";
        }

        return patientDoctorService.findDoctors(keyword, departmentId, cityId, patientId, pageParamVO.getPage(), pageParamVO.getNum());
    }

    /**
     * 查找医生
     *
     * @param keyword      关键字
     * @param departmentId 部门id
     * @param cityId       城市id
     *
     * @return
     *
     * @History 2015年6月23日 上午10:48:11 by Amber
     */
    @ResponseBody
    @RequestMapping("get")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageVO<DoctorVO> getDoctors(String keyword, Integer departmentId, Integer cityId, Long patientId,
        PageParamVO pageParamVO) throws UnsupportedEncodingException, BusinessException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("查找医生(get) 请求参数：keyword = [{}], departmentId = [{}], cityId = [{}], patientId = [{}], pageParamVO = [{}]", keyword, departmentId,
                cityId, patientId, pageParamVO);
        if (keyword == null) {
            keyword = "";
        }

        return patientDoctorService.getDoctors(keyword, departmentId, cityId, patientId, pageParamVO.getPage(), pageParamVO.getNum());

    }

    /**
     * 获取医生简报
     *
     * @param doctorId 医生id
     *
     * @return
     *
     * @History 2015年6月25日 下午2:48:39 by Amber
     */
    @ResponseBody
    @RequestMapping("simple")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public DoctorVO getSimple(Long doctorId) throws Exception {
        LOGGER.info("获取医生简报 请求参数：doctorId = [{}]", doctorId);
        // 参数校验
        if (doctorId == null || doctorId < 0) {
            LOGGER.error("patient doctor simple ERROR ; doctorId is null : doctorId {}", doctorId);
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }
        return patientDoctorService.getSimpleDoctor(doctorId);
    }

    /**
     * 获取医生互联网医院出诊信息（给IM调用）
     *
     * @param doctorId 医生id
     *
     * @return String <互联网医院时间，包括在线状态>
     *
     * @History 2015年7月7日 下午7:03:54 by Amber
     */
    @ResponseBody
    @RequestMapping("online")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getDoctorOnlineInfo(Long doctorId) throws BusinessException {
        if (doctorId == null) {
            LOGGER.error("patient doctor online ERROR ; doctorId is null");
            throw new BusinessException(ExceptionCodes.PARAM_ERROR);
        }
        try {

            boolean isOn = patientDoctorService.validateDoctorOnline(doctorId);
            if (isOn) {
                // 在线
                return "1";
            } else {
                // 不在线
                return "0";
            }
        } catch (Exception e) {
            LOGGER.error("patient doctor online ERROR ; doctorId {}", doctorId, e);
            return "0";
        }
    }

    /**
     * 获取最新的私人医生
     * PatientDoctorController.getNewPersonalDoctor()<BR>
     * <P>Author : Amber </P>
     * <P>Date : 2015年9月11日 </P>
     *
     * @param patientId
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("new")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public DoctorVO getNewPersonalDoctor(Long patientId) throws BusinessException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        // 参数已修复
        if (patientId == null) {
            LOGGER.error("patient doctor new ERROR ; patientId is null");
            throw new BusinessException(ExceptionCodes.PARAM_ERROR);
        }

        return patientDoctorService.getNewPersonalDoctor(patientId);

    }

    /**
     * 更新医生新增数值
     * TODO:缓存优化
     *
     * @param key    缓存key
     * @param change 变化值，可增可减
     *
     * @return void <返回值描述>
     *
     * @History 2015年6月30日 下午8:11:41 by Amber
     */
    private void addDoctorNewNums(String key, int change) {
        try {
            String value = RedisUtil.valueOps().getString(key);
            if (value == null) {
                RedisUtil.valueOps().set(key, "1");
            } else {
                int num = Integer.parseInt(value);
                num += change;
                if (num < 0) {
                    num = 0;
                }
                RedisUtil.valueOps().set(key, num + "");
            }
        } catch (Exception e) {
            LOGGER.error("--------- addDoctorNewNums ERROR ;", e);
        }
    }

    /**
     * 根据患者id查询关注医生列表
     *
     * @return
     *
     * @Description PatientDoctorController.getPrivateDoctorList()
     * @Author linhf
     * @Date 2016年4月21日
     * @since 1.0.0
     */
    @ResponseBody
    @RequestMapping("privateDoctor/my")
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageVO<DoctorVO> getPrivateDoctorList(PatientDoctorVo param) throws PatientBusinessException {

        LOGGER.info("根据患者id查询关注医生列表 请求参数：param = [{}]", param);

        // 校验参数
        if (null == param || param.getPatientId() == null) {
            LOGGER.error("patient doctor list error ; patientId {}", null == param ? "" : param.getPatientId());
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }

        // 设置分页信息 <=0 查询全部
        if (param.getPage() <= 0) {
            param.setPage(1);
        }

        if (param.getNum() <= 0) {
            param.setNum(0);
        }

        return patientDoctorService.getPrivateDoctorList(param.getPatientId(), param.getPage(), param.getNum());

    }

    /**
     * 通过患者ID和医生ID获取患者是否初复诊
     *
     * @param patientId 患者ID
     * @param doctorId  医生ID
     *
     * @return
     */
    @RequestMapping("firstisit")
    @ResponseBody
    @ApiOperation(value = "", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public Object firstisit(Long patientId, Long doctorId) throws BusinessException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        if (patientId == null || doctorId == null) {
            throw new BusinessException(ExceptionCodes.PARAM_ERROR);
        }
        return drMedicationRecomService.firstisit(patientId, doctorId);
    }

    /**
     * @param patientId
     * @param doctorId
     *
     * @return
     *
     * @Title: saveCheckedDoctor
     * @author: chengqiang
     * @Description: 记录处方需求清单患者选中的医生
     * @date: 2018年8月13日 下午1:34:19
     * @return: ResponseVO<Void>
     */
    @ResponseBody
    @RequestMapping("checkedDoctor")
    @ApiOperation(value = "记录处方需求清单患者选中的医生", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({ @ApiImplicitParam(name = "patientId", value = "患者id", required = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "doctorId", value = "医生id", required = true, dataType = "long", paramType = "query") })
    public ResponseVO<Void> saveCheckedDoctor(Long patientId, Long doctorId) {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("记录患者选中的医生 请求参数 patientId={} doctorId={} ", patientId, doctorId);
        try {
            // 参数校验
            if (patientId == null || patientId < 0 || doctorId == null || doctorId < 0) {
                LOGGER.error("记录患者选中的医生 请求参数错误 patientId={} doctorId={}", patientId, doctorId);
                throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
            }
            patientDoctorService.saveCheckedDoctor(patientId, doctorId);
        } catch (PatientBusinessException e) {
            return PublicService.returnResponseVO(e.getCode());
        }

        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }

    /**
     * 校验患者上级医生和私人医生
     * PatientDoctorController.checkRecomAndPersonalDoctor()
     *
     * @param patientId
     *
     * @return
     *
     * @throws PatientBusinessException
     * @Date 2018年9月12日
     * @since 2.24
     */
    @RequestMapping("check")
    @ResponseBody
    @ApiOperation(value = "校验患者上级医生和私人医生", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({ @ApiImplicitParam(name = "patientId", value = "患者id", required = true, dataType = "long", paramType = "query") })
    public ResponseVO<DoctorCheckVO> checkRecomAndPersonalDoctor(Long patientId) throws PatientBusinessException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("校验患者上级医生和私人医生 请求参数 patientId={} ", patientId);
        DoctorCheckVO vo = patientDoctorService.getRecomAndPersonalDoctorInfo(patientId);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS, vo);
    }


    /**
     * 我的医生
     * 根据类型捞取医生列表（私人医生或关注医生）
     *
     * @param patientId   患者id
     * @param pageParamVO 分页参数
     *
     * @return
     *
     * @throws Exception String <返回值描述>
     * @History 2015年6月22日 下午1:28:17 by Amber
     */
    @RequestMapping(value = "my", method = RequestMethod.POST)
    @ApiOperation(value = "我的医生列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE, tags =
            { SwaggerTags.WX_PATIENT_COMPLAINT_COMMENTS })
    public ResponseVO<PageVO<DoctorVO>> myDoctor(Long patientId, PageParamVO pageParamVO, String scene) throws BusinessException, JsonException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("我的医生列表 请求参数 patientId={},pageParamVO={}", patientId, pageParamVO);
        // 参数校验
        if (patientId == null || patientId < 0) {
            LOGGER.error("我的医生列表 请求参数错误 patientId={} pageParamVO={}", patientId, pageParamVO);
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }
        PageVO<DoctorVO> page = patientDoctorService.getMyDoctors(patientId, pageParamVO.getPageable(), scene);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS, page);
    }

    /**
     * 专家名医/义诊医生列表
     *
     * @param departmentId
     * @param cityId
     * @param patientId
     * @param pageParamVO
     *
     * @return
     *
     * @throws BusinessException
     * @throws JsonException
     */
    @RequestMapping(value = "clinic", method = RequestMethod.POST)
    @ApiOperation(value = "义诊医生列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({@ApiImplicitParam(name = "departmentId", value = "科室ID", required = false, dataType = "int", paramType = "query"),
        @ApiImplicitParam(name = "cityId", value = "城市ID", required = false, dataType = "int", paramType = "query"),
        @ApiImplicitParam(name = "patientId", value = "患者id", required = true, dataType = "long", paramType = "query"),
        @ApiImplicitParam(name = "keyword", value = "搜索关键字", required = true, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "labelId", value = "标签ID(1:专家名义, 2:HIS医生)", required = true, dataType = "long",
            paramType = "query"),
        @ApiImplicitParam(name = "page", value = "第几页", required = false, dataType = "long", paramType = "query"),
        @ApiImplicitParam(name = "num", value = "每页记录数", required = false, dataType = "long", paramType = "query")})
    public ResponseVO<PageVO<DoctorVO>> clinicDoctor(Integer departmentId, Integer cityId, Long patientId, String keyword,
        @RequestParam(defaultValue = "1") Long labelId, PageParamVO pageParamVO)
        throws BusinessException, JsonException {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("义诊医生列表 请求参数 pageParamVO={},departmentId={},lableId={}", pageParamVO,departmentId,labelId);
        PageVO<DoctorVO> page = patientDoctorService
            .getClinicDoctorList(departmentId, cityId, patientId, labelId, pageParamVO.getPageable(), keyword);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS, page);
    }

    /**
     * 医生详细信息
     *
     * @param doctorId 医生id
     *
     * @return String <返回值描述>
     *
     * @throws Exception 参数不对、医生不存在
     * @History 2015年6月22日 下午7:31:45 by Amber
     */
    @PostMapping("detail")
    @ApiOperation(value = "医生详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE, tags =
            { SwaggerTags.WX_PATIENT_COMPLAINT_COMMENTS })
    public DoctorVO detail(Long doctorId, Long patientId) throws Exception {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("医生详细信息 请求参数：doctorId={}, patientId={}", doctorId, patientId);

        // 参数校验
        if (doctorId == null || doctorId < 0) {
            LOGGER.error(" patient doctor detail ERROR ; illegal param : doctorId {},patientId {},", doctorId, patientId);
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }
        return patientDoctorService.getDoctorDetail(doctorId, patientId);
    }

    /**
     * 义诊医生详细信息
     */
    @PostMapping("clinic/detail")
    @ApiOperation(value = "义诊医生详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({ @ApiImplicitParam(name = "patientId", value = "患者id", required = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "doctorId", value = "医生ID", required = true, dataType = "long", paramType = "query") })
    public DoctorVO clinicDetail(Long patientId, Long doctorId) throws Exception {
        if (null == patientId) {
            patientId = (Long) ResourceHolder.getResource(SettingConfig.PATIENT_ID);
        }
        LOGGER.info("义诊医生详细信息 请求参数：doctorId={}", doctorId);

        // 参数校验
        if (doctorId == null || doctorId < 0) {
            LOGGER.error(" patient clinicDetail ERROR ; illegal param : doctorId {},", doctorId);
            throw new PatientBusinessException(ExceptionCodes.PARAM_ERROR);
        }
        return patientDoctorService.getClinicDetail(doctorId, patientId);
    }

    @GetMapping("/videoconsult/list")
    @ResponseBody
    @ApiOperation(value = "患者视频咨询列表", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({ @ApiImplicitParam(name = "patientId", value = "患者id", required = true, dataType = "long", paramType = "query") })
    public ResponseVO<PageVO<VideoConsultVO>> videlConsultList(Long patientId) throws BusinessException {
        return null;
    }
}
